package com.web.new12306.service.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import com.web.new12306.dao.AdminDao;
import com.web.new12306.dao.impl.AdminDaoImpl;
import com.web.new12306.pojo.User;
import com.web.new12306.service.AdminService;
import com.web.new12306.util.DaoUtil;


public class AdminServiceImpl  implements AdminService{

	@Override
	public boolean Login(String name, String pwd) {
		Connection conn=DaoUtil.getConnection();
		AdminDao userDao=new AdminDaoImpl();
		return userDao.Login(conn, name, pwd);
		
	}

	@Override
	//查询所有
	public List<User> showAll() {
		Connection conn=DaoUtil.getConnection();
		AdminDao userDao=new AdminDaoImpl();
		return userDao.queryUsers(conn);
	}

	@Override
	public int saveUser(User user) {
		Connection connection=DaoUtil.getConnection();
		AdminDao userDao=new AdminDaoImpl();
		return userDao.saveUser(connection, user);
	}

	@Override
	public List<User> queryUsers(Integer page, Integer rows) {
		// TODO Auto-generated method stub
		Connection connection =DaoUtil.getConnection();
		AdminDao userDao=new AdminDaoImpl();
		List<User> list=userDao.select(connection, page, rows);
		return list;
	}

	@Override
	public int number() {
		// TODO Auto-generated method stub
		Connection conn =DaoUtil.getConnection();
		AdminDao userDao=new AdminDaoImpl();
		int number=userDao.number(conn);
		return number;
	}

	
}
